package com.lagou.homework.one;

public class Coder {
    //私有化成员变量
    private int id;
    private int salary;

    //定义无参数构造方法
    public Coder(){

    }
    //定义有参数构造方法
    public Coder(int id, int salary){
        setId(id);
        setSalary(salary);
    }

    //下面是setter和getter方法
    public void setId(int id) {
        if (id > 0){
            this.id = id;
        }else{
            System.out.println("异常ID");
        }
    }

    public void setSalary(int salary) {
        if (salary > 3000){
            this.salary = salary;
        }else{
            System.out.println("异常salary");
        }
    }

    public int getId() {
        return id;
    }

    public int getSalary() {
        return salary;
    }

    //成员方法work
    public void work(){
        System.out.print("工号为" + getId());
        System.out.println("基本工资为" + getSalary() + "的程序员方便正在努力的写着代码......操作步骤描述");
    }


}
